#pragma once

#include "socket_types.h"

#include <string>
#include <vector>
#include <cstdint>

class InetAddress;
class ServerSocket;
class Socket {
public:
    Socket();
    Socket(socket_type sockfd, InetAddress* address = nullptr);
    bool connect(InetAddress* address);
    void disconnect();
    bool isConnect() const;
    int write(const char* buf, int len);
    int write(const std::vector<char>& buf);
    int write(const std::string& buf);
    std::vector<char> read(int size);
    std::vector<char> readAll();
    InetAddress* address();
    socket_type sockfd() const;
private:
    socket_type sockfd_;
    InetAddress* address_;
    bool isConnect_;
    std::vector<char> writeBuf_;

    friend class ServerSocket;
};


